<?php
namespace App\Repositories;

use App\Exceptions\BasicException;
use Illuminate\Support\Facades\Hash;
use function Matrix\add;    //引入hash

class LisenceCommentRepository
{
    /**
     * 资质评论列表
     * @param  $param
     * @param  $page
     * @param  $perPage
     * @return bool
     */
    public function commentList($param,$page=1,$perPage=20)
    {
        $list = app('model_lisence_comment')->with('lisence_order:order_id,order_no')->with('user_data:user_id,nickname,user_code');
        if (isset($param['ulisence_id'])){
            $list=$list->where('ulisence_id',$param['ulisence_id']);
        }
        if (isset($param['order_id'])){
            $list=$list->where('order_id',$param['order_id']);
        }
        if (isset($param['order_no'])){
            $order_no = $param['order_no'];
            $list=$list->whereHas('lisence_order',function ($query) use($order_no){
                $query->where('order_no','like',"%{$order_no}%");
            });
        }
        if (isset($param['user_code'])){
            $user_code = $param['user_code'];
            $list=$list->whereHas('user_data',function ($query) use($user_code){
                $query->where('user_code','like',"%{$user_code}%");
            });
        }
        $list=$list->orderBy('add_time','desc')->paginate($perPage, ['*'], '', $page);
        return $list;
    }

}


?>